﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using ClassDollar;
using COMOSOFT.ShippingManagement.Dataset;
using System.Data;

namespace COMOSOFT.Production.Report
{
    public partial class rpt_InvTTDP : DevExpress.XtraReports.UI.XtraReport
    {
        Dollar dl = new Dollar();
        DataTable dtAmountPrice, dtAmountExtra;
        double dblTTPrice = 0, dblTTExtra = 0;
        public rpt_InvTTDP(int Inv)
        {
            InitializeComponent();            
            COMOSOFT.ShippingManagement.Dataset.DataSet_ShipMentTableAdapters.sp_rptInvoiceMasterTableAdapter adtM = new ShippingManagement.Dataset.DataSet_ShipMentTableAdapters.sp_rptInvoiceMasterTableAdapter();
            COMOSOFT.ShippingManagement.Dataset.DataSet_ShipMentTableAdapters.sp_rptInvoiceDetailTableAdapter adtD = new ShippingManagement.Dataset.DataSet_ShipMentTableAdapters.sp_rptInvoiceDetailTableAdapter();
            COMOSOFT.ShippingManagement.Dataset.DataSet_ShipMentTableAdapters.sp_rptInvoiceExtraTableAdapter adtE = new ShippingManagement.Dataset.DataSet_ShipMentTableAdapters.sp_rptInvoiceExtraTableAdapter();
            adtM.Fill(dataSet_ShipMent1.sp_rptInvoiceMaster, Inv);
            adtD.Fill(dataSet_ShipMent1.sp_rptInvoiceDetail, Inv);
            adtE.Fill(dataSet_ShipMent1.sp_rptInvoiceExtra, Inv);

            dtAmountPrice = dataSet_ShipMent1.sp_rptInvoiceDetail;
            dtAmountExtra = dataSet_ShipMent1.sp_rptInvoiceExtra;
            for (int i = 0; i < dtAmountPrice.Rows.Count; i++)
            {
                dblTTPrice += Convert.ToDouble(dtAmountPrice.Rows[i]["Amount"]);
            }

            for (int i = 0; i < dtAmountExtra.Rows.Count; i++)
            {
                dblTTExtra += Convert.ToDouble(dtAmountExtra.Rows[i]["Amount"]);
            }
            lb_dolar.Text = (dl.Convert(String.Format("{0:0.##}", dblTTPrice)) + " only./.").ToUpper();
            xrTableFOB.Text = (dblTTPrice - dblTTExtra).ToString("{0:C2}");
        }   
    }
}
